package be.gnx.fogo.application.ui;

import java.util.ResourceBundle;
import java.util.Set;

import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.widgets.Composite;

import be.gnx.fogo.application.model.Person;

public class ChildrenGroup extends AbstractGroup {

  public ChildrenGroup(Composite composite, int style, ResourceBundle resourceBundle) {
    super(composite, style, resourceBundle);
    this.setText("Children");
  }

  protected void setAsFamily(boolean asFamily) {
    super.setAsFamily(asFamily);
    if (asFamily) {
      this.setText("Children");
    } else {
      this.setText("");
    }
  }

  protected void setPersonSet(Set<Person> personSet) {
    if ((personSet != null) && (personSet.size() > 0)) {
      String toolTip = "";
      boolean first = true;
      for (Person person : personSet) {
        if (!first) {
          toolTip += ", ";
        }
        toolTip += person.getAlternativeName().getValue();
        first = false;
      }
      getGroup().setToolTipText(toolTip);
    }
  }

  protected void widgetDisposed(DisposeEvent disposeEvent) {
    // TODO;
  }

  protected void controlResized(ControlEvent controlEvent) {
    resize();
  }

  @Override
  protected void resize() {
    super.resize();
  }

}
